home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1996 March / macformat-035.iso / Shareware City / Developers / ICAppSourceKit1.2 / OSSubs.p < prev    next >
Encoding:
Text File  |  1995-11-07  |  1.1 KB  |  51 lines  |  [TEXT/CWIE]

  1. unit OSSubs;
  2.  
  3. interface
  4.  
  5.     uses
  6.         Types, OSUtils;
  7.         
  8.     function NumToolboxTraps: integer;
  9.     function GetTrapType (theTrap: Integer): TrapType;
  10.     function OurTrapAvailable (theTrap: integer): boolean;
  11.  
  12. implementation
  13.  
  14.     uses
  15.         Traps;
  16.  
  17.     function NumToolboxTraps: integer;
  18.     begin
  19.         if NGetTrapAddress(_InitGraf, ToolTrap) = NGetTrapAddress($AA6E, ToolTrap) then begin
  20.             NumToolboxTraps := $200
  21.         end else begin
  22.             NumToolboxTraps := $400;
  23.         end; (* if *)
  24.     end; (* NumToolboxTraps *)
  25.  
  26.     function GetTrapType (theTrap: integer): TrapType;
  27.         const
  28.             TrapMask = $0800;
  29.     begin
  30.         if band(theTrap, TrapMask) > 0 then begin
  31.             GetTrapType := ToolTrap
  32.         end else begin
  33.             GetTrapType := OSTrap;
  34.         end; (* if *)
  35.     end; (* GetTrapType *)
  36.  
  37.     function OurTrapAvailable (theTrap: integer): boolean;
  38.         var
  39.             tType: TrapType;
  40.     begin
  41.         tType := GetTrapType(theTrap);
  42.         if tType = ToolTrap then begin
  43.             theTrap := band(theTrap, $07FF);
  44.             if theTrap >= NumToolboxTraps then begin
  45.                 theTrap := _Unimplemented;
  46.             end; (* if *)
  47.         end; (* if *)
  48.         OurTrapAvailable := NGetTrapAddress(theTrap, tType) <> NGetTrapAddress(_Unimplemented, ToolTrap);
  49.     end; (* OurTrapAvailable *)
  50.  
  51. end. (* OSSubs *)